package com.Pawtrack.info.service.impl;

import java.util.List;
import com.Pawtrack.common.utils.DateUtils;
import com.Pawtrack.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.Pawtrack.info.mapper.PetHealthMapper;
import com.Pawtrack.info.domain.PetHealth;
import com.Pawtrack.info.service.IPetHealthService;

/**
 * 宠物健康Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-14
 */
@Service
public class PetHealthServiceImpl implements IPetHealthService 
{
    @Autowired
    private PetHealthMapper petHealthMapper;

    /**
     * 查询宠物健康
     * 
     * @param id 宠物健康主键
     * @return 宠物健康
     */
    @Override
    public PetHealth selectPetHealthById(Long id)
    {
        return petHealthMapper.selectPetHealthById(id);
    }

    /**
     * 查询宠物健康列表
     * 
     * @param petHealth 宠物健康
     * @return 宠物健康
     */
    @Override
    public List<PetHealth> selectPetHealthList(PetHealth petHealth)
    {
        // 自动设置当前用户ID，确保只能查询自己的数据
        if (petHealth != null) {
            petHealth.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        }
        return petHealthMapper.selectPetHealthList(petHealth);
    }

    /**
     * 新增宠物健康
     * 
     * @param petHealth 宠物健康
     * @return 结果
     */
    @Override
    public int insertPetHealth(PetHealth petHealth)
    {
        // 自动设置创建人为当前用户ID
        petHealth.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        petHealth.setCreateTime(DateUtils.getNowDate());
        return petHealthMapper.insertPetHealth(petHealth);
    }

    /**
     * 修改宠物健康
     * 
     * @param petHealth 宠物健康
     * @return 结果
     */
    @Override
    public int updatePetHealth(PetHealth petHealth)
    {
        // 自动设置更新人为当前用户ID
        petHealth.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
        petHealth.setUpdateTime(DateUtils.getNowDate());
        return petHealthMapper.updatePetHealth(petHealth);
    }

    /**
     * 批量删除宠物健康
     * 
     * @param ids 需要删除的宠物健康主键
     * @return 结果
     */
    @Override
    public int deletePetHealthByIds(Long[] ids)
    {
        return petHealthMapper.deletePetHealthByIds(ids);
    }

    /**
     * 删除宠物健康信息
     * 
     * @param id 宠物健康主键
     * @return 结果
     */
    @Override
    public int deletePetHealthById(Long id)
    {
        return petHealthMapper.deletePetHealthById(id);
    }
}
